<?php
if(!defined('BZ_XTBLOG') || !defined('BZ_WJSCUZ')) {
	exit('Access Denied');
}
$wzxx_title ='申请加盟-'.$wzxx_title.'';
$wzxx_gj    ='申请加盟-'.$wzxx_gj.'';
$wzxx_ms    ='申请加盟-'.$wzxx_ms.'';
$lid=$_GET['lid'];
$gid =verify_id($_GET['gid']);
$act=$_GET['act'];
$wzxx_url=Bingz_http($wzxx_url);
$sql_li=$db->get_one('link'," ORDER BY `id` DESC LIMIT 0 , 1 ",'');
$yjid=$sql_li['id']+1;
if($act =='ok'){
   $name =$_POST['name'];
   $urla =$_POST['url'];
   $jname=$_POST['jname'];
   $logo =$_POST['logo'];
   $fid  =$_POST['fid'];
   $sqli=$db->get_one('link',"`uip` = '$uip' ORDER BY `id` DESC LIMIT 0 , 1 ",'');
   $wzx_title =Bingz_config('Site_config_name');
   $wzx_titlea=Bingz_config('Site_config_namej');
   $wzx_ms    =Bingz_config('Site_config_description');
   $bzpost=Bingz_config('link_config_post');
   if(!$user_uid){$user_uid='0';}
   if(!$name or !$jname or !$urla){
   	  $pdid='1';
	 }else if((($time - $sqli[time_b])/60) < 11){
		  $pdid='2';
	 }elseif($db->get_one('link',"`url` = '$urla'",'')){
		  $pdid="3";
	 }else if(!is_url($urla)){
		  $pdid='4';
   }else if($db->insert('link',
   '`id` ,`fid`,`uid` ,`uip` ,`name` ,`namem` ,`url`, `click` ,`jlick` ,`logo` ,`type`,`check` ,`time_a` ,`time_b`',
   "NULL , '$fid', '$user_uid', '$ip', '$name', '$jname', '$urla', '0', '0', '$logo', '0', '$bzpost', '0', '$time'" )){
		  $id=$db->insert_id();
      $wzname =$bzxt['w_name'];
      $wznamej=$bzxt['w_namea'];
      $wzjname=$bzxt['w_wzms'];
      $wzurl=$url;
   	  $pdid='5';
   }else{
   	  $pdid='6';
   }
}elseif($act =='xg'){
   $wzx_title =Bingz_config('Site_config_name');
   $wzx_titlea=Bingz_config('Site_config_namej');
   $wzx_ms    =Bingz_config('Site_config_description');
   $sql_lk=$db->query('link_class',"1 ",'');
   while($row=mysql_fetch_array($sql_lk)){
	    $fl[]= array('id' => $row['id'],'name' => $row['name']);
   }
	 $sqli=$db->get_one('link',"`uid`= '$user_uid' AND `id` = '$gid' ",'');
   $name =$sqli['name'];
   $urla =$sqli['url'];
   $jname=$sqli['namem'];
   $logo =$sqli['logo'];
   $fid  =$sqli['fid'];
   $id  =$sqli['id'];
	 $smmi=$db->get_one('link_class',"`id`= '$sqli[fid]' ",'');
   $fname  =$smmi['name'];
	 $pdid='7';
}elseif($act =='xgok'){
   $name =$_POST['name'];
   $urla =$_POST['url'];
   $jname=$_POST['jname'];
   $logo =$_POST['logo'];
   $fid  =$_POST['fid'];
   if(!$name or !$jname or !$urla){
   	  $sjts='提交错误';
	 }else if(!is_url($urla)){
		  $sjts='网址错误';
   }else if($db->update('link'," `name` = '$name',`namem` = '$jname',`url` = '$urla',`logo` = '$logo',`fid` = '$fid' "," `id`= '$gid'")){
		  $sjts='修改成功';
   }else{
		  $sjts='修改失败';
   }	
	 $pdid='8';
}else{
   $sql_lk=$db->query('link_class',"1 ",'');
   while($row=mysql_fetch_array($sql_lk)){
	    $fl[]= array('id' => $row['id'],'name' => $row['name']);
   }
}
@include template('head');
@include template('link/link_post');
@include template('foot');
?>